package com.splant.android.smart.UILevel.Community;

import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.splant.android.R;
import com.splant.android.smart.ModelLevel.ErrorMessageListBean;
import com.splant.android.smart.SystemDefinedLevel.LRecyclerview.base.BaseMultiAdapter;
import com.splant.android.smart.SystemDefinedLevel.LRecyclerview.base.SuperViewHolder;


/**
 * Created by Administrator on 2017/8/19.
 */

public class Garden_MessageList_Adapter extends BaseMultiAdapter<ErrorMessageListBean.ErrorMessage> {


    public Garden_MessageList_Adapter(Context context) {
        super(context);
        addItemType(0, R.layout.garden_messagelist_item);
    }

    @Override
    public void onBindItemHolder(SuperViewHolder holder, final int position) {

        TextView tv_title=holder.getView(R.id.tv_title);
        TextView tv_date=holder.getView(R.id.tv_date);
        TextView tv_content=holder.getView(R.id.tv_content);
        LinearLayout ll_message=holder.getView(R.id.ll_message);

        ErrorMessageListBean.ErrorMessage msg=getDataList().get(position);

        tv_title.setText(msg.getTitle());
        tv_date.setText(msg.getDate());
        tv_content.setText(msg.getContent());

        ll_message.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mListener!=null)
                    mListener.onItemChick(position);

            }
        });

    }

    private onItemClickListener mListener = null;
    public void setOnItemClickListener(onItemClickListener mListener){
        this.mListener=mListener;
    }

    public interface onItemClickListener {
        void onItemChick(int pos);
    }

}
